#include "my_lineedit.h"



my_lineedit::my_lineedit(char* name , QWidget* parent) : QWidget(parent)
{

    this->label = new QLabel(name);
    this->lineedit = new QLineEdit();
    this->lineedit1 = new QLineEdit();
    this->label1 = new QLabel(name);
    this->hboxlayout = new QHBoxLayout();
    this->hboxlayout->setMargin(1);
    this->setLayout(this->hboxlayout);
    this->hboxlayout->addWidget(this->label);
    this->hboxlayout->addWidget(this->lineedit);
    QObject::connect(this , SIGNAL(set_text_signal(const QString &)) , this->lineedit , SLOT(setText(const QString &)));
    QObject::connect(this , SIGNAL(clear_text_signal()) , this->lineedit , SLOT(clear()));
    QObject::connect(this , SIGNAL(set_text_red_signal()) , this , SLOT(set_text_red_slot()));
    QObject::connect(this , SIGNAL(set_text_black_signal()) , this , SLOT(set_text_black_slot()));
}


my_lineedit::my_lineedit(char* name , char* name1 , QWidget* parent) : QWidget(parent)
{

    this->label = new QLabel(name);
    this->label1 = new QLabel(name1);
    this->lineedit = new QLineEdit();
    this->lineedit1 = new QLineEdit();
    this->lineedit1->setReadOnly(1);
    this->hboxlayout = new QHBoxLayout();
    this->hboxlayout->setMargin(1);
    this->setLayout(this->hboxlayout);
    this->hboxlayout->addWidget(this->label);
    this->hboxlayout->addWidget(this->lineedit);
    this->hboxlayout->addWidget(this->label1);
    //this->hboxlayout->addWidget(this->lineedit1);
    QObject::connect(this , SIGNAL(set_text_signal(const QString &)) , this->lineedit , SLOT(setText(const QString &)));
    QObject::connect(this , SIGNAL(clear_text_signal()) , this->lineedit , SLOT(clear()));
    QObject::connect(this , SIGNAL(set_text_red_signal()) , this , SLOT(set_text_red_slot()));
    QObject::connect(this , SIGNAL(set_text_black_signal()) , this , SLOT(set_text_black_slot()));
}




void my_lineedit::set_text(char* str)
{
    emit this->set_text_signal(str);
}



void my_lineedit::clear_text(void)
{
    emit this->clear_text_signal();
}


void my_lineedit::set_text_red(void)
{

    emit set_text_red_signal();
}

void my_lineedit::set_red_text(char* str)
{
    emit set_text_red_signal();
    emit this->set_text_signal(str);
}

void my_lineedit::set_black_text(char* str)
{
    emit set_text_black_signal();
    emit this->set_text_signal(str);
}



void my_lineedit::set_text_red_slot(void)
{
    this->palette.setColor(QPalette::Text , QColor(255,0,0));
    this->lineedit->setPalette(this->palette);
}


void my_lineedit::set_text_black(void)
{

    emit set_text_black_signal();
}


void my_lineedit::set_text_black_slot(void)
{
    this->palette.setColor(QPalette::Text , QColor(0,0,0));
    this->lineedit->setPalette(this->palette);
}



my_lineedit::~my_lineedit()
{
    delete this->label;
    delete this->label1;
    delete this->lineedit;
    //delete this->lineedit1;
}




